package com.example.mymall.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mymall.entity.ShopcartEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.mymall.entity.UserGoodsCartVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author <a href="https://srpihot.site">Srpihot</a>
 * @since 2021-10-06
 */
@Mapper
public interface ShopcartMapper extends BaseMapper<ShopcartEntity> {
    @Select("SELECT shopcart.id as id,shopcart.userid as userid,`user`.username as username,`user`.picture as headimg,`user`.phone as phone,`user`.realname as realname,\n" +
            "\tshopcart.goodsid as goodsid,goods.`name` as goodsname,goods.context as context,goods.price as price,goods.picture as picture \n" +
            "\tFROM shopcart \n" +
            "\t\tINNER JOIN `user` on (shopcart.userid = `user`.id)\n" +
            "\t\tINNER JOIN goods on (shopcart.goodsid = goods.id)\n")
    public IPage<UserGoodsCartVO> selectCartDetailAll(IPage<UserGoodsCartVO> page);

    @Select("SELECT shopcart.id as id,shopcart.userid as userid,`user`.username as username,`user`.picture as headimg,`user`.phone as phone,`user`.realname as realname,\n" +
            "\tshopcart.goodsid as goodsid,goods.`name` as goodsname,goods.context as context,goods.price as price,goods.picture as picture \n" +
            "\tFROM shopcart \n" +
            "\t\tINNER JOIN `user` on (shopcart.userid = `user`.id)\n" +
            "\t\tINNER JOIN goods on (shopcart.goodsid = goods.id)\n")
    public List<UserGoodsCartVO> selecttext();

    @Select("SELECT * FROM shopcart")
    List<ShopcartEntity> selectCart();

}
